home *** CD-ROM | disk | FTP | other *** search
- From: gsobrian@msn.com (Glenn Sobrian)
- Subject: RE: Simple Question for the GURUs....
- Date: 28 Mar 96 22:45:09 -0800
- References: <1996Mar21.093000.3545@mwk.com>
- Message-ID: <00001a81+0000b05c@msn.com>
- Path: news.msn.com!msn.com
- Newsgroups: comp.lang.c++
- Organization: The Microsoft Network (msn.com)
-
- I don't think you can return a pointer from within your program to
- any memory allocated with malloc. The problem here is two-fold.
-
- 1) NT will clean up the Virtual Memory after it has finished running
- your program in its own address space. Thus your pointer is crap by
- the time it is returned.
-
- 2) NT (and any Win32 based environment such as Windows 95) uses
- demand page virtual memory. These memory addresses are "VIRTUAL",
- that means that the address 0FFFFFFA in process A is not the same as
- address 0FFFFFFA in process B. They are both mapped onto different
- protected virtual memory space which is owned by the process. You
- 'may' have gotten away with that little trick in DOS because it
- doesn't do shit for memory management.
-
- I'm not sure how to do what you want to do. Try looking at the API -
- such as doing the memory allocation through Win32 GlobalAlloc. The
- stuff you are doing here is one of the reasons why COM/OLE has been
- developed so you might take a look at using the MFC COleVariant class
- to pass the information to your program somehow.
-
- Hope that helps.
- ---
- Glenn Sobrian
- gsobrian@msn.com
-